import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:star_author/utils/rouces_util.dart';

class PeopleCoverWidget extends StatelessWidget {
  String cover;
  double size;
  String placeholder;

  PeopleCoverWidget(
      {this.size: 44, this.cover: "", this.placeholder: "lt_common/temp_load"});

  @override
  Widget build(BuildContext context) {
    return Container(
      width: size.w,
      height: size.w,
      child: ClipRRect(
          borderRadius: BorderRadius.circular(4),
          child: cover == null ||
                  cover.length == 0 ||
                  cover == "" ||
                  cover == "null"
              ? Container(
                  color: Colors.grey,
                  child: RoucesUtil.getAssetsIcon(placeholder, size.w),
                )
              : CachedNetworkImage(
                  imageUrl: cover,
                  fit: BoxFit.cover,
                )),
    );
  }
}

buildCircleCover({String cover: "", double size: 44}) {
  return ClipRRect(
    child: Container(
      width: size.w,
      height: size.w,
      child: ClipRRect(
          borderRadius: BorderRadius.circular(4.w),
          child: cover == null || cover.length == 0 || cover == ""
              ? Container(
                  color: Colors.grey,
                  child: RoucesUtil.getAssetsIcon('lt_common/temp_load', size.w),
                )
              : CachedNetworkImage(
                  imageUrl: cover,
                  fit: BoxFit.cover,
                  width: size.w,
                  height: size.w,
                )),
    ),
    borderRadius: BorderRadius.circular(50),
  );
}
